function [ex,st] = extrsubf( outpath , rootpath )
% ===============================================================
% EXTRSUBF.m
%
% function [ex,st] = extrsubf( outpath , rootpath );
%
% Extract SUBINDEX from a rootpath 
% e.g. if ROOTPATH = C:\A\B 
% and OUTPATH is C:\A\B\out 
% EX: extracted string is out and 
% STl starting position is 7 
% 
% If not nested then string is rootpath and starting position is []  
% 
% Alejandro Justiniano 9/7/2005 
% ==================================================================
n1 = length( rootpath ); 
n2 = length( outpath  ); 
if n2 < n1;
    ind = 0;
else
    ind = strncmp( outpath , rootpath , n1 );
end

if ind == 0 
    ex = outpath ; 
    st = []; 
else 
    ex = outpath( n1+1:end ); 
    st = n1; 
end 
poselim=findstr(ex,'\'); 
if ~isempty(poselim) 
    ex(poselim)=' '; 
    ex=ex(2:end); 
end 
    